using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class SODUTONKHOInfo
    {
		#region Local Variable
		public enum Field
		{
			NAM,
			MAHANG,
			SOLUONG,
			SOTIEN,
			NGAYLUU
		}
		private String _NAM;
		private String _MAHANG;
		private Double _SOLUONG;
		private Double _SOTIEN;
		private String _NGAYLUU;
		
		public String NAM{	get{ return _NAM;} set{_NAM = value;} }
		public String MAHANG{	get{ return _MAHANG;} set{_MAHANG = value;} }
		public Double SOLUONG{	get{ return _SOLUONG;} set{_SOLUONG = value;} }
		public Double SOTIEN{	get{ return _SOTIEN;} set{_SOTIEN = value;} }
		public String NGAYLUU{	get{ return _NGAYLUU;} set{_NGAYLUU = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public SODUTONKHOInfo()
		{
			_NAM = "";
			_MAHANG = "";
			_SOLUONG = 0;
			_SOTIEN = 0;
			_NGAYLUU = "";
		}
		public SODUTONKHOInfo(
		String NAM,
		String MAHANG,
		Double SOLUONG,
		Double SOTIEN,
		String NGAYLUU
		)
		{
			_NAM = NAM;
			_MAHANG = MAHANG;
			_SOLUONG = SOLUONG;
			_SOTIEN = SOTIEN;
			_NGAYLUU = NGAYLUU;
		}
		public SODUTONKHOInfo(DataRow dr)
		{
			if (dr != null)
			{
				_NAM = dr[Field.NAM.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NAM.ToString()]);
				_MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MAHANG.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_NGAYLUU = dr[Field.NGAYLUU.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NGAYLUU.ToString()]);
			}
		}
		public SODUTONKHOInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_NAM = dr[Field.NAM.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NAM.ToString()]);
				_MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MAHANG.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_NGAYLUU = dr[Field.NGAYLUU.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NGAYLUU.ToString()]);
			}
		}
		public SODUTONKHOInfo(SODUTONKHOInfo objEntr)
		{			
			_NAM = objEntr.NAM;			
			_MAHANG = objEntr.MAHANG;			
			_SOLUONG = objEntr.SOLUONG;			
			_SOTIEN = objEntr.SOTIEN;			
			_NGAYLUU = objEntr.NGAYLUU;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("SODUTONKHO");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.NAM.ToString(), typeof(String)),
				new DataColumn(Field.MAHANG.ToString(), typeof(String)),
				new DataColumn(Field.SOLUONG.ToString(), typeof(Double)),
				new DataColumn(Field.SOTIEN.ToString(), typeof(Double)),
				new DataColumn(Field.NGAYLUU.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.NAM.ToString()] = _NAM;
			row[Field.MAHANG.ToString()] = _MAHANG;
			row[Field.SOLUONG.ToString()] = _SOLUONG;
			row[Field.SOTIEN.ToString()] = _SOTIEN;
			row[Field.NGAYLUU.ToString()] = _NGAYLUU;
			return row;
		}
        #endregion InitTable
    }
}
